package com.cdlj.moes.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cdlj.moes.R;
import com.cdlj.moes.common.ShopInfo;

public class PoiResultAdapter extends BaseAdapter {
	public int count = 10;
	private LayoutInflater mInflater;
	private ArrayList<ShopInfo> mShopInfos;
	int i = 0;

	class ViewHolder {
		TextView mShopName;
		TextView mShopStar;
		TextView mShopAddress;
	}

	public PoiResultAdapter(Context context, ArrayList<ShopInfo> mShopInfos) {
		this.mInflater = LayoutInflater.from(context);
		this.mShopInfos = mShopInfos;
	}

	public int getCount() {
		return count;
	}

	public Object getItem(int arg0) {
		return arg0;
	}

	public long getItemId(int arg0) {
		return arg0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder tmpViewHolder;
		// ShopInfo shopInfo = mShopInfos.get(position);
		ShopInfo shopInfo = null;
		if (convertView == null) {
			tmpViewHolder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.list_result_item, null);
			convertView.setTag(tmpViewHolder);
		} else {
			tmpViewHolder = (ViewHolder) convertView.getTag();
		}
		initValue(convertView, shopInfo, tmpViewHolder, position);
		return convertView;
	}

	private void initValue(View convertView, ShopInfo shopInfo,
			ViewHolder tmpViewHolder, int position) {
		tmpViewHolder.mShopName = (TextView) convertView
				.findViewById(R.id.shopName);
		tmpViewHolder.mShopStar = (TextView) convertView
				.findViewById(R.id.price);
		tmpViewHolder.mShopAddress = (TextView) convertView
				.findViewById(R.id.addr);

		// tmpViewHolder.mShopName.setText(shopInfo.getShopName());
		// tmpViewHolder.mShopStar.setText(shopInfo.getShopStar());
		// tmpViewHolder.mShopAddress.setText(shopInfo.getShopAddress());
		tmpViewHolder.mShopName.setText("hah");
		tmpViewHolder.mShopStar.setText("ehhe");
		tmpViewHolder.mShopAddress.setText("ok"+i++);
	}

}
